<div class="nav">
    <a href="javascript:window.history.back()">会员列表</a>
    <a class="sel" href="{:U('index')}">修改会员</a>
</div>
<div class="add">
    <form method="post" action="" >
        <table class="table_add" cellpadding='8'>
            <tr style="display:none">
                <td width="100px">注册邮箱</td>
                <td style="line-height:26px;">{$model.email}
                    <if condition="empty($model['email'])">
                          <input type="text" name="email" id="email" value="{$model.email}" />
                    </if>
                </td>
            </tr>
            <tr>
                <td>注册手机</td>
                <td style="line-height:26px;">{$model.phone}
                    <if condition="empty($model['phone'])">
                          <input type="text" name="phone" id="phone" value="{$model.phone}" />
                    </if>
                </td>
            </tr>
            <tr style="display:none">
                <td>用户名</td>
                <td style="line-height:26px;">{$model.username} 
                     <if condition="empty($model['username'])">
                          <input type="text" name="username" id="username" value="{$model.username}" />
                    </if>
                </td>
            </tr>
             <tr>
                <td>会员等级</td>
                <td>
                    
                    <select name="level_id" id="level_id" class="sel1">
                        <option value="0">选择级别</option>
                        <foreach name="level_sel" item="lev" key="k">
                        <option value="{$k}">{$lev}</option>
                        </foreach>
                    </select>
                </td>
            </tr>
            <tr>
                <td>使用状态</td>
                <td><select name="status" id="status" class="sel1">
                        <option value="0">选择状态</option>
                        <option value="1">正常</option>
                        <option value="2">禁用</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>真实姓名</td>
                <td><input type="text" name="realname" id="realname" value="{$model2.realname}" /> </td>
            </tr>
            <tr>
                <td>性别</td>
                <td><select name="sex" id="sex" class="sel1">
                        <option value="">未填</option>
                        <option value="男">男</option>
                        <option value="女">女</option>
                    </select></td>
            </tr>
            <tr>
                <td>电话</td>
                <td><input type="text" name="tel" id="tel" value="{$model2.tel}" /> </td>
            </tr>
            <tr>
                <td>QQ</td>
                <td><input type="text" name="qq" id="qq" value="{$model2.qq}" /> </td>
            </tr>
            <tr>
                <td>生日</td>
                <td><select name="year" id="year" class="sel1">
                        <option value="">选择年</option>
                        <for start="1899" end="2015">
                            <option value="{$i}">{$i}年</option>
                        </for>
                    </select>
                    <select name="month" id="month" class="sel1">
                        <option value="">选择月</option>
                        <option value="01">1月</option>
                        <option value="02">2月</option>
                        <option value="03">3月</option>
                        <option value="04">4月</option>
                        <option value="05">5月</option>
                        <option value="06">6月</option>
                        <option value="07">7月</option>
                        <option value="08">8月</option>
                        <option value="09">9月</option>
                        <option value="10">10月</option>
                        <option value="11">11月</option>
                        <option value="12">12月</option>
                    </select>
                    <select name="day" id="day" class="sel1">
                        <option value="">选择日</option>
                        <for start="1" end="10">
                            <option value="0{$i}">{$i}日</option>
                        </for>
                        <for start="10" end="32">
                            <option value="{$i}">{$i}日</option>
                        </for>
                    </select>
                </td>
            </tr>
            <tr>
                <td>所在地区</td>
                <td><span id="span_province">
                        <select name="province" id="province" class="sel1">
                            <option value="">选择省份</option>
                            <foreach name="province" item="prov">
                                <option value="{$prov.province}">{$prov.province}</option>
                            </foreach>
                        </select>
                    </span>
                    <span id="span_city"></span>
                    <span id="span_area"></span>
                    <input type="hidden" id="hid_province" name="hid_province" value="{$model2.province}" />
                    <input type="hidden" id="hid_city" name="hid_city" value="{$model2.city}" />
                    <input type="hidden" id="hid_area" name="hid_area" value="{$model2.area}" />
                </td>
            </tr>
            <tr>
                <td>详细地址</td>
                <td><input type="text" name="address" id="address" style="width:500px" value="{$model2.address}" /> </td>
            </tr>
            <tr>
                <td>邮政编码</td>
                <td><input type="text" name="zip" id="zip"  value="{$model2.zip}" /> </td>
            </tr>
            <tr>
                <td></td>
                <td style="line-height:26px;"> <input type="submit" class="btn1" value="提 交" /> </td>
            </tr>
            <tr>
                <td>积分</td>
                <td style="line-height:26px;">{$model.point} </td>
            </tr>
   
            <tr>
                <td style="line-height:26px;">头像</td>
                <td>
                    <if condition="!empty($model2['headpic'])">
                    <img src="__ROOT__{$model2.headpic}" />
                    </if>
                </td>
            </tr>
            <tr>
                <td style="line-height:26px;">注册时间</td>
                <td>{$model.create_time|date='Y-m-d h:m:s',###} </td>
            </tr>
            <tr>
                <td style="line-height:26px;">注册IP</td>
                <td>{$model2.create_ip} </td>
            </tr>
        </table>
        <input type="hidden" name="member_id" id="member_id" value="{$model.member_id}" />
        <script type="text/javascript">
            $("#level_id").val('{$model.level_id}');
            $("#status").val('{$model.status}');
            $("#sex").val('{$model2.sex}');
            $("#month").val("{$model2.month}");
            $("#year").val("{$model2.year}");
            $("#day").val("{$model2.day}");
            
            //用户地区选择
            $(function () {
                var province = $("#hid_province").val();
                var city = $("#hid_city").val();
                var area = $("#hid_area").val();
                if (province != "") {
                    $("#province").val(province);
                    $("#span_city").load("{:U('Address/city_sel')}?province=" + encodeURI(province) + "&city=" + encodeURI(city));
                    if(city != "") {
                        $("#span_area").load("{:U('Address/area_sel')}?city=" + encodeURI(city) + "&area=" + encodeURI(area));
                    }
                }
                $("#province").change(function(){change_province();});
             })
             
            function change_province() {
                var province = $("#province").val();
                $("#span_city").load("{:U('Address/city_sel')}?province=" + encodeURI(province) + "&city=");
                $("#span_area").html("");
            }

            function change_city() {
                var city = $("#city").val();
                $("#span_area").load("{:U('Address/area_sel')}?city=" + encodeURI(city) + "&area=");
            }
            
            function change_area() {
                var area = $("#area").val();
                $.get("{:U('Address/get_zip')}?area=" + encodeURI(area),function(zip){
                    if(zip != '') {
                        $("#zip").val(zip);
                    }
                });
            }
        </script>
    </form>
</div>
